<?php namespace Admin\Controller;

use Hdphp\Controller\Controller;

//首页控制器
class IndexController extends CommonController{

    //首页
    public function index(){
       View::make();
    }

    public function welcome(){
    	View::make();
    }

    public function updatePassword(){
    	if(IS_POST){
    		$oldPassword = Q('post.oldPassword','','md5');
    		$newPassword = Q('post.newPassword','','md5');
    		$confirmPassword = Q('post.confirmPassword','','md5');
    		$userData = Db::table('admin')->where("uid={$_SESSION['uid']}")->get();
    		if($userData[0]['password'] != $oldPassword){
    			$this->error('原密码错误，请重新输入');
    		}
    		if($newPassword != $confirmPassword){
    			$this->error('两次密码不一致，请重新输入');
    		}
    		Db::table('admin')->where("uid={$_SESSION['uid']}")->update(array("password"=>$newPassword));
    		$this->success('修改成功');
    	}
    	View::make();
    }
}
